import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int len = scan.nextInt() ;
        int[] begin = new int[len];
        int[] finish = new int[len];
        for(int i = 0 ;i < len ; i ++){
            begin[i] = scan.nextInt() ;
            finish[i] = scan.nextInt() ;
        }
        int sum = 0 ;
        for(int i = 0 ;i < len ; i ++){
            int count = 0 ;
            int start = begin[i];
            int end = finish[i] ;
            for(int j = 0 ; j < len ; j ++){
                if(i == j || start == begin[j]){
                    continue ;
                }
                int tmpStart = begin[j] ;
                int tmpEnd = finish[j];
                if(end <= tmpStart){
                    count ++ ;
                }else if(tmpEnd <= start){
                    count ++ ;
                }
                if(sum < count){
                    sum = count ;
                }
            }
        }
        if(sum == 0){
            System.out.println(1);
        }else{
            System.out.println(sum);
        }


    }
}